home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / addcomnt.arc / ADDCOMNT.C next >
C/C++ Source or Header  |  1990-11-28  |  2KB  |  75 lines

  1. /* This program will take an EXEC PC file listing and add the comment in 
  2.    that list to the ZIP file in the local subdirectory matching that name.
  3.    This way you can have PKUNZIP give you a brief summary of what the file
  4.    contains by using 'PKUNZIP /v filename.zip sdfsdfs' where sdfsdfs is a 
  5.    garbage name that won't match anything. This program written by 
  6.    Mike Fleischmann on 11/28/90  with Microsoft C 6.0 and is hereby placed 
  7.    into the public domain. I would like it if you left my name as the orgional
  8.    writer of this software.
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <dos.h>
  14.  
  15. char line[120];
  16. FILE *list,*name;
  17.  
  18. main(argc,argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.     int i,j,k;
  23.     char *cptr;
  24.     struct find_t dbuff;
  25.     char str[70];
  26.     
  27.     if(argc<2 || argv[1][0]=='?')
  28.     {
  29.         printf("Calling format is 'ADDCOMNT filename.lst'\n");
  30.         printf("Where filename.lst is an EXEC PC format file description from the\n");
  31.         printf("file list. (I just did an ascii capture) See sample file that came\n");
  32.         printf("with this package for format example\n\n");
  33.         printf("This program will take an EXEC PC file listing and add the comment in\n");
  34.         printf("that list to the ZIP file in the local subdirectory matching that name.\n");
  35.         printf("This way you can have PKUNZIP give you a brief summary of what the file\n");
  36.         printf("contains by using 'PKUNZIP /v filename.zip sdfsdfs' where sdfsdfs is a\n");
  37.         printf("garbage name that won't match anything. This program written by\n");
  38.         printf("Mike Fleischmann on 11/28/90  with Microsoft C 6.0 and is hereby placed\n");
  39.         printf("into the public domain. I would like it if you left my name as the orgional\n");
  40.         printf("writer of this software.\n");
  41.         printf("I can be reached on EXEC PC under the name of OPTICAL PUBLISHING\n\n\n");
  42.         exit(0);
  43. }
  44.  
  45.     list=fopen(argv[1],"r");
  46.     if(list==NULL)
  47.     {
  48.         printf("couldn't open %s\n",argv[1]);
  49.         exit(0);
  50.     }
  51.     
  52.     fgets(line,120,list);
  53.     while(!feof(list))
  54.     {
  55.         line[12]=0;
  56.         cptr=strchr(line,'.');
  57.         cptr++;
  58.         if(memcmp(cptr,"ZIP",3)==0)
  59.         {
  60.             i=_dos_findfirst(line,_A_NORMAL,&dbuff);
  61.             if(i==0)        /* if the file is there */
  62.             {
  63.                 name=fopen("name","w");
  64.                 fprintf(name,"%s",&line[27]);
  65.                 fclose(name);
  66.                 printf("\n %s -- %s",line, &line[27]);
  67.                 sprintf(str,"pkzip /z %s < name >NUL",line);
  68.                 system(str); 
  69.             }
  70.         } 
  71.         fgets(line,120,list);
  72.     }
  73.     fclose(list);
  74. }
  75.